<template>
	<view>
		<view style="line-height:100rpx;font-size:40rpx;background:#fff;padding:0 30rpx;box-sizing: border-box;font-weight: bold;">
			解绑银行卡
		</view>
		<form>
			<view class='addAddress'>
				<view class='list'>
					<view class='item acea-row row-between-wrapper' style="border-top:none;">
						<view class='name'><em style="color:#f00;margin-right:10rpx;">*</em>银行名称</view>
						<input type='text' placeholder='请填写银行名称' disabled v-model="show_data.bankName"
							placeholder-class='placeholder'></input>
					</view>
					<view class='item acea-row row-between-wrapper' style="position:relative;">
						<view class='name'><em style="color:#f00;margin-right:10rpx;">*</em>银行卡号</view>
						<input type='text' placeholder='请输入银行卡号' disabled  v-model="show_data.bankCardNo"
							placeholder-class='placeholder'></input>
						<image :src="show_data.bankico" v-if="show_data.bankico" class="bankIcon"></image>	
					</view>
				</view>
				<button class='keepBnt bg-color' @click="submitFunc">解绑</button>
			</view>
		</form>
	</view>
</template>

<script>
	import {
		getAllBank,
		setModifyBankSubmit
	} from '@/api/directSelling.js'
	import {
		shop_ht,
	} from '@/config/app_member.js';
	export default {
		data() {
			return {
				getBankData: {
				  token: "",
				  memberCode: "",
				  memberType: 3,
				  bankCode: null
				},
				show_data: {
					bankCardNo:"",
					bankName:"",
					bankico:""
				},
				postData: {
				  token: "",
				  memberCode: "",
				  memberType: 3,
				},
				sendData: {
				  token:"",
				  memberCode: "",
				  memberType: 3,
				  cardNo: null
				}
			};
		},
		mounted() {
			this.getBankData.token = this.$w_md5.hex_md5_32Upper('tlGetBankType' + uni.getStorageSync('userInfo')
				.memberCode);	
			this.getBankData.memberCode = uni.getStorageSync('userInfo').memberCode || "";
			this.postData.token = this.$w_md5.hex_md5_32Upper('tlQueryBankCard' + uni.getStorageSync('userInfo')
				.memberCode);	
			this.postData.memberCode = uni.getStorageSync('userInfo').memberCode || "";
			this.sendData.token = this.$w_md5.hex_md5_32Upper('tlUnbindBankCard' + uni.getStorageSync('userInfo')
				.memberCode);	
			this.sendData.memberCode = uni.getStorageSync('userInfo').memberCode || "";
			this.tlQueryBankCard()
		},
		methods: {
			tlQueryBankCard(){
				uni.request({
					url: shop_ht + '/shop_ht/manage/tlQueryBankCard.do',
					method: "get",
					data: this.postData,
					success: (res) => {
						if(res.data.status==1){
							this.show_data.bankCardNo=res.data.bankCardNo;
							this.show_data.bankName=res.data.bankName;
							this.sendData.cardNo = res.data.bankCardNo
							this.cardNoBlur();
						}else{
							this.show_data.bankCardNo="";
							this.show_data.bankName="";
							this.sendData.cardNo = "";
						}
					}
				})
			},
			cardNoBlur(){
				if(this.show_data.bankCardNo){
					this.getBankData.bankCode=this.show_data.bankCardNo;
					uni.request({
						url: shop_ht + '/shop_ht/manage/tlGetBankType.do',
						method: "get",
						data: this.getBankData,
						success: (res) => {
							if(res.data.status==1){
								this.show_data.bankico=res.data.bankico;
							}else{
								this.show_data.bankico="";
							}
						}
					})
				}
			},
			//解绑数据
			submitFunc(){
				let that=this;
				uni.showModal({
					title: '提示',
					content: "确定要解绑吗?",
					showCancel: true,
					confirmText: '确定',
					success:function(){
						this.sendData
						uni.request({
							url: shop_ht + '/shop_ht/manage/tlUnbindBankCard.do',
							method: "get",
							data: that.sendData,
							success: (res) => {
								if(res.data.status==1){
									that.$util.Tips({
										title: '解绑成功！'
									})
									setTimeout(()=>{
										uni.navigateBack();
									},1500)
								}else{
									that.$util.Tips({
										title: `${res.data.msg}`
									});
								}
							}
						})
					}
				});
			}
			
		}
	}
</script>

<style scoped lang="scss">
	.addAddress .list {
		background-color: #fff;
		padding: 0 30rpx;
		box-sizing: border-box;
	}

	.addAddress .list .item {
		padding: 30rpx 0rpx;
		border-top: 1rpx solid #eee;
	}

	.addAddress .list .item .name {
		width: 210rpx;
		font-size: 30rpx;
		color: #333;
	}

	.addAddress .list .item .address {
		// width: 412rpx;
		flex: 1;
		margin-left: 20rpx;
	}

	.addAddress .list .item input {
		width: 470rpx;
		font-size: 30rpx;
		text-align: left;
	}

	.addAddress .list .item .placeholder {
		color: #ccc;
	}

	.addAddress .list .item picker {
		width: 410rpx;
		height: 42rpx;
	}

	.addAddress .list .item picker .picker {
		width: 350rpx;
		font-size: 30rpx;
		text-align: right;
	}

	.addAddress .list .item picker .iconfont {
		font-size: 43rpx;
	}

	.addAddress .default {
		padding: 0 30rpx;
		height: 90rpx;
		background-color: #fff;
		margin-top: 23rpx;
	}

	.addAddress .default checkbox {
		margin-right: 15rpx;
	}

	.addAddress .keepBnt {
		width: 690rpx;
		height: 86rpx;
		border-radius: 50rpx;
		text-align: center;
		line-height: 86rpx;
		margin: 50rpx auto;
		font-size: 32rpx;
		color: #fff;
	}

	.addAddress .wechatAddress {
		width: 690rpx;
		height: 86rpx;
		border-radius: 50rpx;
		text-align: center;
		line-height: 86rpx;
		margin: 0 auto;
		font-size: 32rpx;
		color: #fe960f;
		border: 1px solid #fe960f;
	}

	.dxCodeBox {
		position: absolute;
		right: 10rpx;
		top: 30rpx;
		color: #f00;
		font-size: 28rpx;
	}

	.messageBox {
		padding: 20rpx 30rpx;
		box-sizing: border-box;
		margin-top: 20rpx;
	}
	.bankIcon{
		position:absolute;
		right:0;
		top:30rpx;
		width:130rpx;
		height:40rpx;
	}
</style>
